package com.mewpipe.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.mewpipe.dao.DaoFactory;
import com.mewpipe.dao.VideoDao;
import com.mewpipe.entity.UserSession;
import com.mewpipe.entity.Video;
@SuppressWarnings("serial")
@WebServlet("/ListVideo")
public class GetAllVideoByUserId extends HttpServlet{
	
	private VideoDao videoDao;
	
	@Override
	public void init() throws ServletException {
		videoDao = DaoFactory.getInstance().getVideoDao();
		
	}
	
		
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		

		HttpSession session= req.getSession();
		UserSession usersession = (UserSession) session.getAttribute("UserSession");
		long id = usersession.getId();
		

		
		List<Video> listvideo = null;
		listvideo = videoDao.getVideoByUserId(id);
		req.setAttribute("Listvideo",(List<Video>) listvideo);
		
		req.getRequestDispatcher("/ListVideo.jsp").forward(req, resp);
		
	
	}


	
	
	
	
}
